package com.chenyaowei.happyhub.utils;

import jdk.dynalink.beans.StaticClass;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

import java.util.Objects;

@Component
public class ArrowUtils {
    static String down = "ti-arrow-down";
    static String vertical = "ti-arrows-vertical";
    static String up = "ti-arrow-up";
    public static Model setAttribute(Model model,String sort,String status){
        if (sort.equals("id")&&status.equals(up)){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", vertical);
            model.addAttribute("idStatus", down);
        }else if(sort.equals("id")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", vertical);
            model.addAttribute("idStatus", up);
        }
        if (sort.equals("meta")&&status.equals(up)){
            model.addAttribute("idStatus", vertical);
            model.addAttribute("metaStatus", down);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", vertical);
        }else if(sort.equals("meta")){
            model.addAttribute("metaStatus", up);
            model.addAttribute("idStatus", vertical);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", vertical);
        }

        if (sort.equals("salesPrice")&&status.equals(up)){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("idStatus", vertical);
            model.addAttribute("salesPriceStatus", down);
            model.addAttribute("salesVolumeStatus", vertical);
        }else if(sort.equals("salesPrice")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("salesPriceStatus", up);
            model.addAttribute("idStatus", vertical);
            model.addAttribute("salesVolumeStatus", vertical);
        }

        if (sort.equals("salesVolume")&&status.equals(up)){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("idStatus", vertical);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", down);
        }else if(sort.equals("salesVolume")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("idStatus", vertical);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", up);
        }

        if(Objects.equals(sort, "")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("idStatus", vertical);
            model.addAttribute("salesPriceStatus", vertical);
            model.addAttribute("salesVolumeStatus", vertical);
        }
        return model;
    }
    public static Model setAttributeOrder(Model model,String sort,String status){
        if (sort.equals("date")&&status.equals(up)){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", vertical);
            model.addAttribute("dateStatus", down);
        }else if(sort.equals("date")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", vertical);
            model.addAttribute("dateStatus", up);
        }
        if (sort.equals("meta")&&status.equals(up)){
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("metaStatus", down);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", vertical);
        }else if(sort.equals("meta")){
            model.addAttribute("metaStatus", up);
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", vertical);
        }

        if (sort.equals("totalPrice")&&status.equals(up)){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("totalPriceStatus", down);
            model.addAttribute("goodNumStatus", vertical);
        }else if(sort.equals("totalPrice")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("totalPriceStatus", up);
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("goodNumStatus", vertical);
        }

        if (sort.equals("goodNum")&&status.equals(up)){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", down);
        }else if(sort.equals("goodNum")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", up);
        }

        if(Objects.equals(sort, "")){
            model.addAttribute("metaStatus", vertical);
            model.addAttribute("dateStatus", vertical);
            model.addAttribute("totalPriceStatus", vertical);
            model.addAttribute("goodNumStatus", vertical);
        }
        return  model;
    }
}
